package http

import (
	"fmt"
	"im/server/http"
)

// 解决跨域问题的中间件

func init()  {
	http.Middlewares = []http.Handler{
		http.Handler(Cross),
	}
}

func Cross(ctx *http.Context)  {
	ctx.Response.Header().Set("Access-Control-Allow-Origin", "*")
	ctx.Response.Header().Set("Access-Control-Allow-Methods", "POST,GET,OPTIONS")
	fmt.Println("===>>> 设置跨域 ===>>> ")
	ctx.Next()
}
